﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Sqls_DBTableList : Page
{
    public int fid = 0;
    //List<Model.Boards> list = BLL.Boards.instance.GetList("");
    private DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        litercopyright.Text = "版权所有,试用版请勿用于商业用途!38809972@qq.com";
        dt =DbHelperSQL.GetShemaTable_SqlServer();
        BindData();
    }

    private void BindData()
    {
        
        gvList.DataSource = dt;
        gvList.DataBind();
    }

  
    protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")        
        {
            string tablename = e.CommandArgument.ToString();
            //Dukey.DBUtility.DbHelperSQL.(tablename);
            BindData();
        }
    }
    protected void gvList_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    public void UpdateTables(string conn, string tablename)
    {
        //ADOX.CatalogClass cate = new CatalogClass();
        //cate.ActiveConnection = DbHelper.webstr;
        //cate.Tables[""].Columns["fds"].Properties["fds"].Value = "fdsf";
    }
    protected void dropSort_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (dropSort.SelectedValue != "incms")
        {           
            DataView dv = dt.DefaultView;
            dv.RowFilter = "table_name like '" + dropSort.SelectedValue + "%'";
            gvList.DataSource = dv;
            gvList.DataBind();
        }
        else
        {         
            DataView dv = dt.DefaultView;
            dv.RowFilter = "table_name not like 'Sys_%'  and table_name not like  'U_%'";
            gvList.DataSource = dv;
            gvList.DataBind();
        }
        radtype.SelectedIndex = 0;
    }

    
    protected void radtype_SelectedIndexChanged(object sender, EventArgs e)
    {
        switch (radtype.SelectedIndex)
        {
            case 0: dt =DbHelperSQL.GetShemaTable_SqlServer(); break;
            case 1: dt =DbHelperSQL.GetShemaView_SqlServer(); break;
            case 2: dt =DbHelperSQL. GetStroProcedure_SqlServer(); break;
        }
        BindData();
    }
}

